<template>
  <!-- 基本信息卡片 -->
  <el-card class="basic-info-card" shadow="hover">
    <h3 class="section-title">基本信息</h3>
    <div class="info-wrapper">
      <div class="info-columns-container">
        <!-- 左侧信息列 -->
        <div class="info-column left">
          <div class="info-item">
            <span class="label">老人姓名：</span>
            <span class="value">{{ basicData.elderName || '白玛多吉' }}</span>
          </div>
          <div class="info-item">
            <span class="label">性别：</span>
            <span class="value">{{ basicData.sex === 'female' ? '女' : '男' || '女' }}</span>
          </div>
          <div class="info-item">
            <span class="label">床位号：</span>
            <span class="value">{{ basicData.bedNumber || '101-1' }}</span>
          </div>
        </div>
        <!-- 右侧信息列 -->
        <div class="info-column right">
          <div class="info-item">
            <span class="label">护理等级：</span>
            <span class="value">{{ basicData.nursingLevel || '三级护理等级' }}</span>
          </div>
          <div class="info-item">
            <span class="label">年龄：</span>
            <span class="value">{{ basicData.age || '124' }}</span>
          </div>
          <div class="info-item">
            <span class="label">护理员姓名：</span>
            <span class="value">{{ basicData.nursingStaffName || '护理员' }}</span>
          </div>
        </div>
      </div>
      <!-- 头像 -->
      <div class="avatar-box">
        <el-image
          :src="basicData.avatar || defaultAvatar"
          :preview-src-list="[basicData.avatar || defaultAvatar]"
          :preview-options="{ center: true }"
          fit="cover"
          class="avatar"
        />
      </div>
    </div>
  </el-card>

  <!-- 护理项目卡片 -->
  <el-card class="nursing-project-card" shadow="hover" style="margin-top: 0;">
    <h3 class="section-title">护理项目</h3>
    <div class="info-wrapper">
      <div class="info-column left">
        <div class="info-item">
          <span class="label">护理项目名称：</span>
          <span class="value">{{ projectData.projectName || '心理咨询' }}</span>
        </div>
        <div class="info-item">
          <span class="label">执行状态：</span>
          <span class="value">
            {{ projectData.status === 1 ? '待执行' : projectData.status === 2 ? '已执行' : '已取消' }}
          </span>
        </div>
        <div class="info-item">
          <span class="label">创建人：</span>
          <span class="value">{{ projectData.taskType === 2 ? '系统' : projectData.creator || '' }}</span>
        </div>
        <div class="info-item">
          <span class="label">期望服务时间：</span>
          <span class="value">{{ projectData.estimatedServerTime || '2023-10-15 19:00:00' }}</span>
        </div>
      </div>
      <div class="info-column right">
        <div class="info-item">
          <span class="label">关联单据：</span>
          <span class="value">{{ projectData.relNo || 'ZD202310161729431' }}</span>
        </div>
        <div class="info-item">
          <span class="label">项目类型：</span>
          <span class="value">{{ projectData.taskType === 2 ? '护理计划内' : '护理计划外' }}</span>
        </div>
        <div class="info-item">
          <span class="label">创建时间：</span>
          <span class="value">{{ projectData.createTime || '2023-10-16 04:29:43' }}</span>
        </div>
        <div class="info-item">
          <span class="label">备注信息：</span>
          <span class="value">{{ projectData.remark || '--' }}</span>
        </div>
      </div>
    </div>
  </el-card>

  <!-- 执行记录卡片 -->
  <el-card class="execute-record-card" shadow="hover" style="margin-top: 0;">
    <h3 class="section-title">执行记录</h3>
    <div class="info-wrapper">
      <div class="info-column left">
        <div class="info-item">
          <span class="label">执行人：</span>
          <span class="value">{{ executeData.executor || '超级管理员' }}</span>
        </div>
        <div class="info-item">
          <span class="label">执行时间：</span>
          <span class="value">{{ executeData.executeTime || '2023-10-16 22:17:07' }}</span>
        </div>
        <div class="info-item">
          <span class="label">执行图片：</span>
          <el-image
            :src="executeData.image || defaultExecuteImg"
            :preview-src-list="[executeData.image || defaultExecuteImg]"
            :preview-options="{ center: true }"
            fit="cover"
            class="execute-image"
          />
        </div>
        <div class="info-item">
          <span class="label">执行记录：</span>
          <span class="value">{{ executeData.remark || '已执行' }}</span>
        </div>
      </div>
    </div>
  </el-card>
</template>

<script setup>
defineProps({
  basicData: {
    type: Object,
    default: () => ({})
  },
 projectData: {
    type: Object,
    default: () => ({
      projectName: '心理咨询',
      relNo: 'ZD202310161729431',
      status: 2, 
      taskType: 1, 
      creator: '顾廷烨', 
      createTime: '2023-10-16 04:29:43',
      estimatedServerTime: '2023-10-15 19:00:00',
      remark: '--'
    })
  },
  executeData: {
    type: Object,
    default: () => ({})
  }
})

// 无头像时的默认占位图
const defaultAvatar = 'https://yjy-slwl-oss.oss-cn-hangzhou.aliyuncs.com/61032c27-43eb-49cc-86df-ba8cbeb2c27d.png';
// 执行记录默认图片
const defaultExecuteImg = 'https://yjy-slwl-oss.oss-cn-hangzhou.aliyuncs.com/61032c27-43eb-49cc-86df-ba8cbeb2c27d.png';
</script>

<style scoped>
/* 通用样式：标题、信息项对齐 */
.section-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 16px;
}

.info-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 16px;
}

.info-columns-container {
  display: flex;
  width: calc(100% - 120px);
  justify-content: space-between;
}

.info-column {
  display: flex;
  flex-direction: column;
  width: 48%;
}

.info-item {
  display: flex;
  margin-bottom: 12px;
  align-items: center;
}

.label {
  width: 140px;
  color: #606266;
  white-space: nowrap;
}

.value {
  color: #303133;
  white-space: nowrap;
}

/* 基本信息卡片样式 */
.basic-info-card {
  margin-bottom: 0;
}

.avatar-box {
  width: 90px;
  height: 90px;
  align-self: flex-start;
}

.avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

/* 护理项目卡片样式 */
.nursing-project-card {
  margin-top: 0;
  margin-bottom: 0;
}

/* 执行记录卡片样式 */
.execute-record-card {
  margin-top: 0;
}

.execute-image {
  width: 180px;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
}
</style>